import os
from openai import OpenAI
import openai

client = OpenAI(
    # x1
    api_key="NZqKCStAhnPgzYxeedqv:MLftHIXgoeRTbmkACUHD",  # 两种方式：1、http协议的APIpassword； 2、ws协议的apikey和apisecret 按照ak:sk格式拼接；
    base_url="https://spark-api-open.xf-yun.com/v2",
)

# stream_res = True
stream_res = False

stream = client.chat.completions.create(
    messages=[
        {
            "role": "user",
            "content": "你好"
        },

    ],

    model="x1",
    stream=stream_res,
    user="AI面试官",

)
print(stream.choices[0].message.content)